<template>
  <div class="app-container app-content">
    <el-row class="line-bottom" v-show="showSearch">
      <el-col class="form_col">
        <el-form :model="queryParams" ref="queryForm" :size="formItemSize" v-show="showSearch"
                 :label-width="labelWidth">
          <div id="searchFilter" style="display: flex; flex-wrap: wrap;">
            <el-form-item label="报表类型" prop="reportType">
              <el-radio-group v-model="queryParams.reportType" size="mini"
                              @input="handleLogTypeChange">
                <el-radio-button label="day">日</el-radio-button>
                <el-radio-button label="month">月</el-radio-button>
                <el-radio-button label="range">阶段</el-radio-button>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="设备编号" prop="terminalId">
              <el-input :size="formItemSize"
                        style="width: 100%;"
                        v-model="queryParams.terminalId"
                        placeholder="请输入设备编号"
                        clearable
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="IMEI" prop="imei">
              <el-input :size="formItemSize"
                        style="width: 100%;"
                        v-model="queryParams.imei"
                        placeholder="请输入IMEI"
                        clearable
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item label="时间" prop="freezeTime">
              <el-date-picker :size="formItemSize" key="dayDatePicker"
                              style="width: 100%;"
                              v-model="queryParams.dayFreezeTime"
                              placeholder="请选择时间"
                              :clearable="true"
                              type="date"
                              value-format="yyyy-MM-dd"
                              v-if="queryParams.reportType === 'day'"/>
              <el-date-picker :size="formItemSize" key="monthDatePicker"
                              style="width: 100%;"
                              v-model="queryParams.monthFreezeTime"
                              placeholder="请选择时间"
                              clearable
                              type="month"
                              value-format="yyyy-MM"
                              v-if="queryParams.reportType === 'month'"/>
              <el-date-picker :size="formItemSize" key="rangeDatePicker"
                              style="width: 100%;"
                              v-model="rangeFreezeTime"
                              placeholder="请选择时间"
                              :clearable="false"
                              type="daterange"
                              value-format="yyyy-MM-dd"
                              range-separator="至"
                              start-placeholder="开始日期"
                              end-placeholder="结束日期"
                              v-if="queryParams.reportType === 'range'"/>
            </el-form-item>
            <el-form-item label="设备名称" prop="terminalName" label-width="80px">
              <el-input :size="formItemSize"
                        style="width: 100%;"
                        v-model="queryParams.terminalName"
                        placeholder="请输入设备名称"
                        clearable
                        @keyup.enter.native="handleQuery"/>
            </el-form-item>
            <el-form-item style="width: 0;"></el-form-item>
          </div>
        </el-form>
      </el-col>

      <el-col class="form_query">
        <el-button v-show="collapseAble" type="text" size="mini" @click="shiftCollapseAble" class="text">
                    <span>
                      {{ fold ? '收起筛选' : '更多筛选' }}
                    </span>
        </el-button>
        <el-button type="primary" @click="handleQuery" size="mini">查询</el-button>
        <el-button @click="resetQuery" size="mini">重置</el-button>
      </el-col>
    </el-row>

    <el-row :gutter="10" class="mb8">
      <RightDropdown :columns="dayColumns" v-if="queryParams.reportType==='day'"
                     :showSearch.sync="showSearch" @queryTable="getList"
                     @export="handleDayExport"></RightDropdown>
      <RightDropdown :columns="monthColumns" v-if="queryParams.reportType==='month'"
                     :showSearch.sync="showSearch" @queryTable="getList"
                     @export="handleMonthExport"></RightDropdown>
      <RightDropdown :columns="rangeColumns" v-if="queryParams.reportType==='range'"
                     :showSearch.sync="showSearch" @queryTable="getList"
                     @export="handleRangeExport"></RightDropdown>
    </el-row>

    <el-row>
      <el-table ref="dayTable" key="dayTable" v-loading="loading" :data="dayDataList" border size="mini"
                :height="getAvailableHeight" v-if="queryParams.reportType==='day'"
                :default-sort="defaultSort" @sort-change="handleSorterChange">
        <el-table-column type="index" label="#" width="40" align="center" fixed/>
        <el-table-column label="本次冻结时间" align="center" prop="getTimeN" width="150"
                         v-if="dayColumns[0].visible" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column label="设备名称" align="center" prop="terminalName" v-if="dayColumns[1].visible"
                         :show-overflow-tooltip="true" width="150" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="设备编号" align="center" prop="terminalId" v-if="dayColumns[2].visible"
                         :show-overflow-tooltip="true" width="180" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="IMEI" align="center" prop="imei" v-if="monthColumns[3].visible"
                         :show-overflow-tooltip="true" width="130" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上次正向累计读数(m³)" align="center" prop="readNumberO" v-if="dayColumns[4].visible"
                         :show-overflow-tooltip="true" width="175" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="本次正向累计读数(m³)" align="center" prop="readNumberN" v-if="dayColumns[5].visible"
                         :show-overflow-tooltip="true" width="175" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上次累计反向读数(m³)" align="center" prop="reverseNumberO"
                         v-if="dayColumns[6].visible" :show-overflow-tooltip="true" width="175" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="本次累计反向读数(m³)" align="center" prop="reverseNumberN"
                         v-if="dayColumns[7].visible" :show-overflow-tooltip="true" width="175" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上期冻结日的总流量(m³)" align="center" prop="totalFlowO"
                         v-if="dayColumns[8].visible" :show-overflow-tooltip="true" width="195" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="本期冻结日的总流量(m³)" align="center" prop="totalFlowN"
                         v-if="dayColumns[9].visible" :show-overflow-tooltip="true" width="195" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="本次正向日用量(m³)" align="center" prop="readDosageN"
                         v-if="dayColumns[10].visible"
                         :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上期正向日用量(m³)" align="center" prop="readDosageO"
                         v-if="dayColumns[11].visible" :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上次反向日用量(m³)" align="center" prop="reverseDosageO"
                         v-if="dayColumns[12].visible" :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="本次反向日用量(m³)" align="center" prop="reverseDosageN"
                         v-if="dayColumns[13].visible" :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="本次净用量(m³)" align="center" prop="dosageN" v-if="dayColumns[14].visible"
                         :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上次净用量(m³)" align="center" prop="dosageO" v-if="dayColumns[15].visible"
                         :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="累计读数增长率(%)" align="center" prop="readGrowthRate"
                         v-if="dayColumns[16].visible" :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="反向累计读数增长率(%)" align="center" prop="reverseGrowthRate"
                         v-if="dayColumns[17].visible" :show-overflow-tooltip="true" width="195" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="累计流量增长率(%)" align="center" prop="totalFlowGrowthRate"
                         v-if="dayColumns[18].visible" :show-overflow-tooltip="true" width="175" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="用量增长比率(%)" align="center" prop="readDosageGrowthRate"
                         v-if="dayColumns[19].visible" :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="反向用量增长比率(%)" align="center" prop="reverseDosageGrowthRate"
                         v-if="dayColumns[20].visible" :show-overflow-tooltip="true" width="175" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="用量增长比率(%)" align="center" prop="dosageGrowthRate"
                         v-if="dayColumns[21].visible" :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上次冻结时间" align="center" prop="getTimeO" width="150"
                         v-if="dayColumns[22].visible" :show-overflow-tooltip="true" sortable="custom"
                         :sort-orders="['ascending','descending']">
        </el-table-column>
        <!--        <el-table-column label="夜间最小瞬时流量(m³/h)" align="center" prop="readDosageForNight"-->
        <!--                         v-if="dayColumns[23].visible" :show-overflow-tooltip="true" width="180"/>-->
        <!--        <el-table-column label="夜间最小瞬时流量出现时间" align="center" prop="reverseDosageForNight"-->
        <!--                         v-if="dayColumns[24].visible" :show-overflow-tooltip="true" width="180"/>-->
        <!--        <el-table-column label="夜间最小流量(m³/h)" align="center" prop="minNightFlow"-->
        <!--                         v-if="dayColumns[25].visible" :show-overflow-tooltip="true" width="140"/>-->
        <!--        <el-table-column label="夜间最小流量出现时间" align="center" prop="minNightFlowTime"-->
        <!--                         v-if="dayColumns[26].visible" :show-overflow-tooltip="true" width="160"/>-->
        <!--        <el-table-column label="昨日夜间最小流量(m³/h)" align="center" prop="minNightFlowo"-->
        <!--                         v-if="dayColumns[27].visible" :show-overflow-tooltip="true" width="170"/>-->
        <!--        <el-table-column label="环比(%)" align="center" prop="minNightFlowSequential"-->
        <!--                         v-if="dayColumns[28].visible" :show-overflow-tooltip="true" width="90"/>-->
        <!--        v-if="dayColumns[29].visible"-->
        <el-table-column label="瞬时流量平均值(m³/h)" align="center" prop="averageFlow" width="185"
                         v-if="dayColumns[23].visible"
                         :show-overflow-tooltip="true" sortable="custom" :sort-orders="['ascending','descending']"/>
        <el-table-column label="最小压力(MPa)" align="center" prop="minPressN" v-if="dayColumns[24].visible"
                         :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="昨日最小压力(MPa)" align="center" prop="minPressO" v-if="dayColumns[25].visible"
                         :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="最小压力环比(%)" align="center" prop="minPressSequential"
                         v-if="dayColumns[26].visible" :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="最大压力(MPa)" align="center" prop="maxPressN" v-if="dayColumns[27].visible"
                         :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="昨日最大压力(MPa)" align="center" prop="maxPresO" v-if="dayColumns[28].visible"
                         :show-overflow-tooltip="true" width="165" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="最大压力环比(%)" align="center" prop="maxPressSequential"
                         v-if="dayColumns[29].visible" :show-overflow-tooltip="true" width="145" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
      </el-table>

      <el-table ref="monthTable" key="monthTable" v-loading="loading" :data="monthDataList" border size="mini"
                :height="getAvailableHeight" v-if="queryParams.reportType==='month'"
                :default-sort="defaultSort" @sort-change="handleSorterChange">
        <el-table-column type="index" label="#" width="40" align="center" fixed/>
        <el-table-column label="冻结月份" align="center" prop="freezeTime" v-if="monthColumns[0].visible"
                         :show-overflow-tooltip="true" width="100"/>
        <el-table-column label="设备名称" align="center" prop="terminalName" v-if="monthColumns[1].visible"
                         :show-overflow-tooltip="true" sortable="custom" :sort-orders="['ascending','descending']"/>
        <el-table-column label="设备编号" align="center" prop="terminalId" v-if="monthColumns[2].visible"
                         :show-overflow-tooltip="true" width="150" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="IMEI" align="center" prop="imei" v-if="monthColumns[3].visible"
                         :show-overflow-tooltip="true" width="140" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="正向月用量(m³)" align="center" prop="readDosageN" v-if="monthColumns[4].visible"
                         :show-overflow-tooltip="true" width="140" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="反向月用量(m³)" align="center" prop="reverseDosageN"
                         v-if="monthColumns[5].visible" :show-overflow-tooltip="true" width="140" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="净用量(m³)" align="center" prop="dosageN" v-if="monthColumns[6].visible"
                         :show-overflow-tooltip="true" width="140" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="累计正向读数(m³)" align="center" prop="readNumberN" v-if="monthColumns[7].visible"
                         :show-overflow-tooltip="true" width="160" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="累计反向读数(m³)" align="center" prop="reverseNumberN"
                         v-if="monthColumns[8].visible" :show-overflow-tooltip="true" width="160" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="累计总流量(m³)" align="center" prop="totalFlowN" v-if="monthColumns[9].visible"
                         :show-overflow-tooltip="true" width="140" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
      </el-table>

      <el-table ref="rangeTable" key="rangeTable" v-loading="loading" :data="rangeDataList" border size="mini"
                :height="getAvailableHeight" v-if="queryParams.reportType==='range'"
                :default-sort="defaultSort" @sort-change="handleSorterChange">
        <el-table-column type="index" label="#" width="40" align="center" fixed/>
        <el-table-column label="设备名称" align="center" prop="terminalName" v-if="rangeColumns[0].visible"
                         :show-overflow-tooltip="true" sortable="custom" :sort-orders="['ascending','descending']"/>
        <el-table-column label="设备编号" align="center" prop="terminalId" v-if="rangeColumns[1].visible"
                         :show-overflow-tooltip="true" sortable="custom" :sort-orders="['ascending','descending']"/>
        <el-table-column label="IMEI" align="center" prop="imei" v-if="rangeColumns[2].visible"
                         :show-overflow-tooltip="true" width="150" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="阶段正向用量(m³)" align="center" prop="forwardDosage"
                         v-if="rangeColumns[3].visible"
                         :show-overflow-tooltip="true" width="160" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="阶段反向用量(m³)" align="center" prop="reverseDosage"
                         v-if="rangeColumns[4].visible"
                         :show-overflow-tooltip="true" width="160" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="阶段净用量(m³)" align="center" prop="totalDosage"
                         v-if="rangeColumns[5].visible" :show-overflow-tooltip="true" width="160" sortable="custom"
                         :sort-orders="['ascending','descending']"/>
        <el-table-column label="上次冻结日期" align="center" prop="getTimeO" v-if="rangeColumns[6].visible"
                         :show-overflow-tooltip="true" width="140"/>
        <el-table-column label="本次冻结日期" align="center" prop="getTimeN"
                         v-if="rangeColumns[7].visible"
                         :show-overflow-tooltip="true" width="160"/>
      </el-table>
      <pagination
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
      />
    </el-row>
  </div>
</template>

<script>
import moment from 'moment'
import {
  listTerminalsdayfreezedb,
  listTerminalsDayRangeFreezeDbData
} from "@/api/dataquery/terminal/terminalsdayfreezedb";
import {listTerminalsmonfreezedb} from "@/api/dataquery/terminal/terminalsmonfreezedb";

export default {
  name: "Command",
  dicts: ['concentrator_command', 'terminal_supplier'],
  data() {
    return {
      screenHeight: null,
      collapseAble: false,
      fold: false,
      maxShow: '4',
      labelWidth: '80px',
      formItemSize: 'mini',
      defaultProps: {
        children: "children",
        label: "name",
      },
      // 区域树选项
      sheetsTreeList: [],
      dayDataList: [],
      // 列信息
      dayColumns: [
        {key: 0, label: `本次冻结时间`, visible: true},
        {key: 1, label: `设备名称`, visible: true},
        {key: 2, label: `设备编号`, visible: true},
        {key: 3, label: `IMEI`, visible: true},
        {key: 4, label: `上次正向累计读数`, visible: false},
        {key: 5, label: `本次正向累计读数`, visible: true},
        {key: 6, label: `上次累计反向读数`, visible: false},
        {key: 7, label: `本次累计反向读数`, visible: true},
        {key: 8, label: `上期冻结日的总流量`, visible: false},
        {key: 9, label: `本期冻结日的总流量`, visible: true},
        {key: 10, label: `本次正向日用量`, visible: true},
        {key: 11, label: `上期正向日用量`, visible: false},
        {key: 12, label: `上次反向日用量`, visible: false},
        {key: 13, label: `本次反向日用量`, visible: true},
        {key: 14, label: `本次净用量`, visible: true},
        {key: 15, label: `上次净用量`, visible: false},
        {key: 16, label: `累计读数增长率`, visible: true},
        {key: 17, label: `反向累计读数增长率`, visible: true},
        {key: 18, label: `累计流量增长率`, visible: true},
        {key: 19, label: `用量增长比率`, visible: true},
        {key: 20, label: `反向用量增长比率`, visible: true},
        {key: 21, label: `用量增长比率`, visible: true},
        {key: 22, label: `上次冻结时间`, visible: false},
        // {key: 23, label: `夜间最小瞬时流量`, visible: true},
        // {key: 24, label: `夜间最小瞬时流量出现时间`, visible: true},
        // {key: 25, label: `夜间最小流量`, visible: true},
        // {key: 26, label: `夜间最小流量出现时间`, visible: true},
        // {key: 27, label: `昨日夜间最小流量`, visible: true},
        // {key: 28, label: `环比`, visible: true},
        {key: 29, label: `瞬时流量平均值`, visible: true},
        {key: 30, label: `最小压力`, visible: false},
        {key: 31, label: `昨日最小压力`, visible: false},
        {key: 32, label: `最小压力环比`, visible: false},
        {key: 33, label: `最大压力`, visible: false},
        {key: 34, label: `昨日最大压力`, visible: false},
        {key: 35, label: `最大压力环比`, visible: false},
      ],
      monthDataList: [],
      monthColumns: [
        {key: 0, label: `冻结月份`, visible: true},
        {key: 1, label: `设备名称`, visible: true},
        {key: 2, label: `设备编号`, visible: true},
        {key: 3, label: `IMEI`, visible: true},
        {key: 4, label: `正向日用量`, visible: true},
        {key: 5, label: `反向日用量`, visible: true},
        {key: 6, label: `净用量`, visible: true},
        {key: 7, label: `累计正向读数`, visible: true},
        {key: 8, label: `累计反向读数`, visible: true},
        {key: 9, label: `总流量`, visible: true},
      ],
      rangeDataList: [],
      rangeColumns: [
        {key: 0, label: `设备名称`, visible: true},
        {key: 1, label: `设备编号`, visible: true},
        {key: 2, label: `IMEI`, visible: true},
        {key: 3, label: `阶段正向用量`, visible: true},
        {key: 4, label: `阶段反向用量`, visible: true},
        {key: 5, label: `阶段净用量`, visible: true},
        {key: 6, label: `上次冻结日期`, visible: true},
        {key: 7, label: `本次冻结日期`, visible: true},
      ],
      // 默认排序
      defaultSort: {prop: 'dosageN', order: 'descending'},
      // 树状态
      treeVisible: true,
      // 遮罩层
      treeLoading: true,
      loading: false,
      // 显示搜索条件
      showSearch: true,
      reportType: '日用量',
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        reportType: 'day',
        terminalId: null,
        terminalName: null,
        imei: null,
        dayFreezeTime: moment().subtract(1, 'day').format('YYYY-MM-DD'),
        monthFreezeTime: moment().subtract(1, 'month').format('YYYY-MM'),
        rangeStartFreezeTime: null,
        rangeEndFreezeTime: null,
        toUnderScore: true,
      },
      rangeFreezeTime: [moment().subtract(3, 'day').format('YYYY-MM-DD'), moment().subtract(1, 'day').format('YYYY-MM-DD')],
      // 总条数
      total: 0,
      showtime: true,
    };
  },
  created() {
    this.screenHeight = document.body.clientHeight
  },
  computed: {
    getAvailableHeight() {
      return this.screenHeight - (this.showSearch ? (this.fold ? 265 : 225) : 180)
    }
  },
  mounted() {
    // 通过最大显示个数控制展开/折叠
    if (this.maxShow > 0) {
      this.minShowControl()
    }
    this.getList()
  },
  methods: {
    /** 排序触发事件 */
    handleSorterChange({column, prop, order}) {
      this.queryParams.orderByColumn = prop
      this.queryParams.isAsc = order
      this.getList()
    },
    /** 检查设置排序字段 */
    checkSortColumn() {
      if (!this.queryParams.orderByColumn) {
        this.queryParams.orderByColumn = this.defaultSort.prop
        this.queryParams.isAsc = this.defaultSort.order
        this.queryParams.isAsc = this.defaultSort.order
      }
    },
    handleLogTypeChange() {
      if (this.queryParams.reportType === 'day') {
        this.defaultSort.prop = 'getTimeN'
        this.queryParams.toUnderScore = true
      } else if (this.queryParams.reportType === 'month') {
        this.defaultSort.prop = 'dosageN'
        this.queryParams.toUnderScore = true
      } else {
        this.defaultSort.prop = 'totalDosage'
        this.queryParams.toUnderScore = false
      }
      this.defaultSort.order = 'descending'
      this.queryParams.orderByColumn = this.defaultSort.prop
      this.queryParams.isAsc = this.defaultSort.order
      this.getList()
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList()
    },
    // 重置表单
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        reportType: this.queryParams.reportType,
        terminalId: null,
        terminalName: null,
        imei: null,
        dayFreezeTime: null,
        monthFreezeTime: null,
        rangeStartFreezeTime: null,
        rangeEndFreezeTime: null,
      }
      this.handleQuery()
    },
    // 获取表格数据
    getList() {
      this.checkSortColumn()
      this.loading = true;
      if (this.queryParams.reportType === 'day') {
        listTerminalsdayfreezedb(this.queryParams).then(res => {
          this.loading = false;
          if (res.code === 200) {
            this.dayDataList = res.rows
            this.total = res.total
          } else {
            this.$modal.msgError("数据查看失败!")
          }
        })
      } else if (this.queryParams.reportType === 'month') {
        listTerminalsmonfreezedb(this.queryParams).then(res => {
          this.loading = false;
          if (res.code === 200) {
            this.monthDataList = res.rows
            this.total = res.total
          } else {
            this.$modal.msgError("数据查看失败!")
          }
        })
      } else {
        this.queryParams.rangeStartFreezeTime = this.rangeFreezeTime[0]
        this.queryParams.rangeEndFreezeTime = this.rangeFreezeTime[1]
        listTerminalsDayRangeFreezeDbData(this.queryParams).then(res => {
          this.loading = false;
          if (res.code === 200) {
            this.rangeDataList = res.rows
            this.total = res.total
          } else {
            this.$modal.msgError("数据查看失败!")
          }
        })
      }
      this.$nextTick(() => {
        this.$refs.table.doLayout()
      })
    },
    // 展开折叠按钮
    shiftCollapseAble() {
      this.fold = !this.fold
      this.minShowControl()
    },
    // 通过maxShow控制元素显示/折叠
    minShowControl() {
      const group = window.document.querySelectorAll(`#searchFilter .el-form-item.el-form-item--${this.formItemSize}`)
      const len = group?.length ? group?.length : 0
      if (this.maxShow < len) {
        group.forEach((item, index) => {
          if (index > this.maxShow - 1 && index < len) {
            item.hidden = !this.fold
          }
        })
        this.collapseAble = true
      } else {
        this.collapseAble = false
      }
    },
    /** 导出按钮操作 */
    handleDayExport() {
      this.download('datastatistics/terminalsdayfreezedb/exportDay', {
        ...this.queryParams,
      }, `大用户表综合日报表数据.xlsx`)
    },
    handleMonthExport() {
      this.download('datastatistics/terminalsmonfreezedb/exportMonth', {
        ...this.queryParams,
      }, `大用户表综合月报表数据.xlsx`)
    },
    handleRangeExport() {
      this.download('datastatistics/terminalsdayfreezedb/exportRange', {
        ...this.queryParams,
      }, `大用户表综合阶段报表数据.xlsx`)
    }
  }
};
</script>
